///////////////////////////////////////////////////////////////
//	File Name	:	"CGame.h"
//
//	Author Name	:	Michael Schoell (MS)
//	
//	Purpose		:	To encapsulate all game related code.
///////////////////////////////////////////////////////////////

#include "SGD Wrappers/CSGD_Direct3D.h"
#include "SGD Wrappers/CSGD_DirectInput.h"
#include "SGD Wrappers/CSGD_DirectSound.h"
#include "SGD Wrappers/CSGD_TextureManager.h"
#include "SGD Wrappers/CSGD_WaveManager.h"
#include "IListener.h"
#include "CEvents.h"
#include "CMessager.h"

#ifndef _CGAME_H_
#define _CGAME_H_


class IGameState;

class CGame : public IListener
{
private:
	//	Singleton Pointers
	CSGD_Direct3D*				m_pD3D;
	CSGD_DirectInput*			m_pDI;
	CSGD_DirectSound*			m_pDS;
	CSGD_TextureManager*		m_pTM;
	CSGD_WaveManager*			m_pWM;

	int		m_nScreenWidth;
	int		m_nScreenHeight;
	bool	m_bIsWindowed;

	IGameState*	m_pGameState;

	float m_fElapsedTime;
	DWORD m_dwPrevTime;

	//	Proper Singleton:
	//		Constructor
	CGame(void);

	//		Trilogy of Evil
	//		Copy Constructor
	CGame(const CGame&);

	//		Assignment Operator
	CGame& operator=(const CGame&);

	//		Destructor
	~CGame(void);

	bool Input(void);
	void Update(void);
	void Render(void);

public:
	//	Singleton accessor
	static CGame* GetInstance(void);

	//	3 steps a game goes through in its lifetime.
	//		1.	Initialization
	void Initialize(HWND hWnd, HINSTANCE hInstance, int nScreenWidth, int nScreenHeight, bool bIsWindowed);

	//		2.	Execution
	bool Main(void);

	//		3.	Clean Up
	void Shutdown(void);

	void ChangeState(IGameState* pGameState);

	int GetScreenWidth(void) { return m_nScreenWidth; };
	int GetScreenHeight(void) { return m_nScreenHeight; };

	void HandleEvents( CEvents* pEvents );
	static void MessageProc( CMessager* pMsg );
};

#endif